from django.db import models

from apps.users.models import UserProfile
from apps.case.models import Case
from apps.report.models import Report

# Create your models here.


class CaseResult(models.Model):
    """
        测试用例模型
        """
    result = (
        (0, 'SUCCESS'),
        (1, 'FAILURE'),
        (2, 'ERROR'),
        (3, 'SKIP')
    )
    name = models.CharField(max_length=100, verbose_name='结果名称')
    case = models.ForeignKey(Case, on_delete=models.CASCADE, blank=True, null=True, verbose_name='测试用例id')
    report = models.ForeignKey(Report, on_delete=models.CASCADE, blank=True, null=True, verbose_name='测试报告id')
    result = models.CharField(choices=result, max_length=4, verbose_name='执行结果')
    log = models.TextField(max_length=1000, blank=True, null=True, verbose_name='执行日志')
    add_time = models.DateTimeField(auto_now_add=True, verbose_name=u'创建时间')
    edit_time = models.DateTimeField(auto_now=True, verbose_name=u'修改时间')

    class Meta:
        db_table = 't_case_result'
        verbose_name = u'用例结果库'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name
